﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataModel.Models
{
    public class AuthenticationManager
    {
        UniversityPortalEntities entityModel;

        public AuthenticationManager()
        {
            entityModel = new UniversityPortalEntities();
        }

        public bool ValidationCheck(string login, string password)
        {
            var res = false;
            try
            {
                User user = entityModel.Users.First(usr => usr.login == login);
                if ((new Hasher()).VerifyMd5Hash(password, user.password))
                    res = true;
            }
            catch
            {
                res = false;
            }

            return res;
        }
    }
}
